<?php
/**
 * Install Script
 */
class Dbinit_model extends Model {
	function Dbinit_model() {
		parent::Model();
	}

	function database_config($host,$user,$pass,$database,$prefix = '') {
		$config['hostname'] = $host;
		$config['username'] = $user;
		$config['password'] = $pass;
		$config['database'] = $database;
		$config['dbdriver'] = "mysql";
		$config['dbprefix'] = $prefix;
		$config['pconnect'] = FALSE;
		$config['db_debug'] = TRUE;
		$this->load->database($config);
	}

	function create_structure($prefix) {
		$sql = "DROP TABLE IF EXISTS `".$prefix."message`;
		CREATE TABLE `".$prefix."message` (
		  `id` int(11) NOT NULL auto_increment,
		  `userid` int(11) NOT NULL,
		  `operate` smallint(6) NOT NULL,
		  `content` varchar(255) character set gbk NOT NULL,
		  `create` datetime NOT NULL,
		  `update` datetime NOT NULL,
		  `del` tinyint(4) NOT NULL default '0',
		  PRIMARY KEY  (`id`)
		) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;";
		$arrSql = explode(";",$sql);
		foreach($arrSql as $v) {
			if(!empty($v)) {
				$this->db->query($v);
			}
		}
	}

	function insert_initdata() {
		;
	}
}
?>